package com.example.databindingdemo;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.databindingdemo.databinding.ActivityRecyclerBinding;

/**
 * @author: tuyrt7 on 2020/9/8.
 */
public class RecyclerActivity extends AppCompatActivity {


    private ActivityRecyclerBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_recycler);

        binding.recycler.setLayoutManager(new LinearLayoutManager(this));
        MyAdapter adapter = new MyAdapter(new RecyclerViewViewModel().getBooks());
        binding.recycler.setAdapter(adapter);
        binding.recycler.setHasFixedSize(true);
    }
}
